package org.midy.infrastructure.exception;

public class SelectionKeyCancelException extends RuntimeException{
    public SelectionKeyCancelException() {
    }

    public SelectionKeyCancelException(String message) {
        super(message);
    }

    public SelectionKeyCancelException(String message, Throwable cause) {
        super(message, cause);
    }

    public SelectionKeyCancelException(Throwable cause) {
        super(cause);
    }

    public SelectionKeyCancelException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
        super(message, cause, enableSuppression, writableStackTrace);
    }

    public static void throwException(String message, Throwable cause) {
        if(message != null && cause != null) {
            throw new SelectionKeyCancelException(message, cause);
        }

        if(message == null && cause == null) {
            throw new SelectionKeyCancelException();
        }

        throw (message == null ? new SelectionKeyCancelException(cause) : new SelectionKeyCancelException(message));
    }
}
